-- Test selection:        Interger, Double, String, Boolean
-- Arithmetic operators:  +, -, *, /
-- Program-ID:            TVar.lua
-- OS:                    Windows
-- Compiler:              Eclipse/Lua Development Tools


-- Integer and double
a = 1
b = a*2

c = 1.2;
d = c+2;

e = 3; f = e-2;
g = 6  h = g/2 --vaild, but semicolon is better practice

-- String
st1 = "one string"
st2 = string.gsub(st1, "one", "another") -- change string parts
st3 = 'hi' --  can use " or '
st3 = "10" + 1 -- auto conversion between strings and numbers
st4 = "5" + "6" -- auto conversion between two numeric strings
st5 = "5 + 6" -- won't convert inside string

-- Boolean
ans1 = true
ans2 = false
ans3 = not ans1 and ans2
if ans3 == false then
  print("answer is false")
else
  print("answer is true")
end
-- auto compare method, prints result ex. true
print( "2 == 3 ", 2 == 3 )
print( '2 ~= 3 ', 2 ~= 3 )
print( '2 >  3 ', 2 >  3 )
print( '2 <  3 ', 2 <  3 )
print( '2 >= 3 ', 2 >= 3 )
print( '2 <= 3 ', 2 <= 3 )

print(a)
print(b)
print(c)
print(d)
print(e)
print(f)
print(g .. " " .. h)
print(st1)
print(st2)
print(st3)
print(st4)
print(st5)

print("Press exit to exit.....")
re = io.read()
